//
//  PreferentialLeftTableViewCell.m
//  Project_A Gary
//
//  Created by leilei on 16/4/1.
//  Copyright © 2016年 www.lei.com. All rights reserved.
//

#import "PreferentialLeftTableViewCell.h"

@implementation PreferentialLeftTableViewCell

-(void)dealloc{
    
    [_backView release];
    [_modelName release];
    [_dealerName release];
    [_dealerPrice release];
    [_modelPrice release];
    [_phoneBtn release];
    [_preferentialBtn release];
    [_originalPriceFixed release];
    [_presentPriceFixed release];
    [super dealloc];
}

#pragma mark - 初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        // 背景图
        self.backView = [[UIView alloc] init];
        self.backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.backView];
        [_backView release];
        
        // 车型号
        self.modelName = [[UILabel alloc] init];
        self.modelName.font = [UIFont systemFontOfSize:20];
        [self.contentView addSubview:self.modelName];
        [_modelName release];
        
        // 4s店名
        self.dealerName = [[UILabel alloc] init];
        //self.dealerName.backgroundColor = [UIColor greenColor];
        self.dealerName.font = [UIFont systemFontOfSize:15];
        self.dealerName.textColor = [UIColor grayColor];
        [self.contentView addSubview:_dealerName];
        [_dealerName release];
        
        // 原价左边标签
        self.originalPriceFixed = [[UILabel alloc] init];
        self.originalPriceFixed.font = [UIFont systemFontOfSize:12];
        self.originalPriceFixed.textAlignment = NSTextAlignmentRight;
        self.originalPriceFixed.text = @"原价(万元):";
        [self.contentView addSubview:_originalPriceFixed];
        [_originalPriceFixed release];
        
        // 原价价格
        self.dealerPrice = [[UILabel alloc] init];
        //self.dealerPrice.backgroundColor = [UIColor blackColor];
        self.dealerPrice.textColor = [UIColor redColor];
        self.dealerPrice.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_dealerPrice];
        [_dealerPrice release];
        
        // 电话按钮
        self.phoneBtn = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.phoneBtn.backgroundColor =  [UIColor colorWithRed:191 / 255.0 green:202 / 255.0 blue:230 / 255.0 alpha:1];
        self.phoneBtn.layer.borderWidth = 1;
        self.phoneBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        [self.phoneBtn setTitle:@"电话咨询" forState:UIControlStateNormal];
        [self.contentView addSubview:_phoneBtn];
        
        // 优惠按钮
        self.preferentialBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        self.preferentialBtn.backgroundColor = [UIColor colorWithRed:191.0 / 255.0 green:202.0 / 255.0 blue:230.0 / 255.0 alpha:1];
        self.preferentialBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.preferentialBtn.layer.borderWidth = 1;
        [self.preferentialBtn setTitle:@"我要优惠" forState:UIControlStateNormal];
        [self.contentView addSubview:_preferentialBtn];
        
    }
    return self;
}


#pragma mark - 布局方法
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backView.frame = CGRectMake(0, 5, self.contentView.frame.size.width, self.contentView.frame.size.height - 10);
    
    self.modelName.frame = CGRectMake(10, 5, self.contentView.frame.size.width - 20, 40);
    
    self.dealerName.frame = CGRectMake(self.modelName.frame.origin.x, self.modelName.frame.size.height + 10, self.modelName.frame.size.width * 2 / 3, 30);
    
    self.dealerPrice.frame = CGRectMake(self.contentView.frame.size.width * 6 / 7 - 10, self.dealerName.frame.origin.y + 10, self.contentView.frame.size.width / 6 - 10, 25);
    
    // 价格左边标签
    self.originalPriceFixed.frame = CGRectMake(self.dealerPrice.frame.origin.x - 100, self.dealerPrice.frame.origin.y, 100, 26);
    
    // 右边优惠按钮
    self.preferentialBtn.frame = CGRectMake((self.contentView.frame.size.width + 2) / 2 - 1, self.contentView.frame.size.height * 2 / 3 + 10, (self.contentView.frame.size.width + 2) / 2, self.contentView.frame.size.height / 4);
   
    
    // 左边电话咨询按钮
    self.phoneBtn.frame = CGRectMake(-1, self.contentView.frame.size.height * 2 / 3 + 10, (self.contentView.frame.size.width + 2) / 2, self.contentView.frame.size.height / 4);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
